package testing;

import gamemngr.GameMngr;
import gamemngr.HelpMenu;
import junit.framework.TestCase;
import logic.Country;
import logic.GameMap;
import logic.Missions;
import logic.Player;
import logic.moves.SettleMove;

public class GameMngrTest extends TestCase {

	public GameMngrTest(String name) {
		super(name);
	}

	protected void setUp() throws Exception {
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}
	
	public void testHelpMenu(){
		HelpMenu help = new HelpMenu("helpTest.txt");
		assertEquals(help.toString(), "Test\n");
	}
	
	public void testExecuteCommand(){
		GameMngr game = new GameMngr();
		game.executeCommand("exit", 0);
		assertEquals(game.isGameOver(), true);
		assertEquals(game.isCommited(), true);
	}

	public void testSaveLoad(){
		GameMngr game = new GameMngr();
		Player player = new Player("Me",new GameMngr());
		GameMap map = new GameMap();
		Country Israel = map.getCountries().get("Israel");
		game.addPlayer(player);
		SettleMove set = new SettleMove(Israel, player);
		player.addMove(set, false);
		Missions m = new Missions(map, game.getPlayers());
		player.setSecretMission(m.getMission(player));
		game.saveFromConsoleGame();
		GameMngr newGame = new GameMngr();
		newGame.loadGameFromConsole();
		assertEquals(game.playerExists("Me"), true);
		assertEquals(Israel.hasOwner(), true);
		assertEquals(player.hasCountry(Israel), true);
	}
}
